/*******************************************
 * Copyright 2007 Aphrodite Framework for javaME .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * Email : owner@aphroditeme.dev.java.net
 * Contributors:
 *     Kent Elton - initial API and implementation
 *******************************************/

package com.aphrodite.util;

import java.io.InputStream;

/**
 * A resource file reader
 * <p>
 * Internally it is just another {@link Properties}
 * </p>
 * 
 * @author kentelt
 * 
 */
public final class ResourceBundle extends Properties {
	final String resourceName;

	public ResourceBundle(InputStream is, String name) {
		super(is);
		resourceName = name;
	}

	public ResourceBundle(String path) {
		super(path);
		this.resourceName = path;

	}

	public String find(String name) {
		return get(name);
	}

	/**
	 * Formats the value<br/> Format a string like "Where is {0}, in the {1}"
	 * with the corresponding <code>args</code> values.
	 * 
	 * @param name
	 * @param params
	 * @return The formatted string
	 */
	public String format(String name, Object[] params) {
		String value = get(name);
		return StringUtil.format(value, params);
	}

	public String getResourceName() {
		return resourceName;
	}

}
